/**
 * 项目名：五位一体化工安全信息平台
 * 日期：    2019-12-03 14:14:47
 * Copyright (c) 2015- joysuch-版权所有
 */
package com.joysuch.wwyt.bp.repository;

import com.joysuch.wwyt.bp.entity.BpManufacturingTech;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.domain.Specification;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.querydsl.QuerydslPredicateExecutor;
import org.springframework.data.repository.query.Param;

import java.util.List;


/**
 * BpManufacturingTechDao
 */
public interface BpManufacturingTechDao extends JpaRepository<BpManufacturingTech, Long>, QuerydslPredicateExecutor<BpManufacturingTech> {
    public Page<BpManufacturingTech> findAll(Specification<BpManufacturingTech> spec, Pageable pageable);

    public BpManufacturingTech save(BpManufacturingTech bean);

    public void delete(BpManufacturingTech bean);

    @Query(value = "SELECT * FROM wwyt_bp_manufacturing_tech WHERE delete_flag = '0' and if(:name !='',name like %:name%,1=1) order by id desc", nativeQuery = true)
    List<BpManufacturingTech> findByNameOrderByIdDesc(@Param("name") String name);
}
